using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;

namespace LastFMPPC
{
	class Helper
	{
		/// <summary>
		/// Calculate the MD5 hash
		/// </summary>
		public static string CalculateMD5(string input)
		{
			MD5 md = MD5CryptoServiceProvider.Create();
			UTF8Encoding enc = new UTF8Encoding();
			byte[] buffer = enc.GetBytes(input);
			byte[] hash = md.ComputeHash(buffer);
			string md5 = String.Empty;
			for (int i = 0; i < hash.Length; i++)
			{
				md5 += hash[i].ToString("x2");
			}
			return md5;
		}

		[DllImport("coredll.dll")]
		static extern void SystemIdleTimerReset();

		/// <summary>
		/// Frequently calling this method will avoid suspend mode.
		/// </summary>
		public static void IdleTimerReset()
		{
			SystemIdleTimerReset();
		}
	}
}
